<?php 
require_once('../../libraryfiles/config.php');
$view = (isset($_GET['view'])) ? $_GET['view'] : '';
$include = '<script src="' . base_url . 'js/jquery.validate.js" type="text/javascript"></script>';

switch ($view) {
	case 'add' :
		if(isset($_GET['id'])){
			$id=(int)$_GET['id'];   
	   	}
	   	else if(isset($_POST['id'])){
			$id=$_POST['id'][0];
	   	}
	  	else $id = 0;
	   
		$site_title = "Administrator Site - Add New Category";
		$content = 'add.php';
		break;
		
	case 'modify' :
		$site_title = "Administrator Site - Add New Category";
		$content = 'add.php';
		break;
	
	case 'delete' : 
		$sql = "DELETE FROM tblpages WHERE id=".$_GET['id'];
		mysql_query($sql);
		header("Location:".base_url_admin."/pages/index.php?message=del");
		break;	
		
	case 'publish' :
		if (isset($_GET['id']) && (int)$_GET['id'] > 0) {
			$id = (int)$_GET['id'];
		} else {
			header('Location: index.php');
			exit();
		}
		
		if(isset($_GET['publish']) && (int)$_GET['publish']>=0 && (int)$_GET['publish']<=1){
			$publish = (int)$_GET['publish'];

		}
		 else {
			header('Location: index.php');
			exit();
		}
		
		//Statement to publish/unpublish User
		publish('tblpages',$publish,$id);
		$sql_pub = "UPDATE tblpages SET status = $publish WHERE id = $id";
		mysql_query($sql_pub);
		
		header("Location:".base_url_admin."/pages/index.php".getAllGetParams(array('view','id','publish')));//page=".$page."&");
		exit();
		break;

	default :
		$site_title = "Administrator | Blog"; //Set Title of our page
		$content 	= 'list.php';
		break;
}

require_once TMP_ADMIN_PATH;
?>